<?php 
/**
 *  $version $Id: shortcut.php 9 2010-03-28 17:32:13Z webbochsant $
 *  @package	Joomla
 *  @author		Daniel Eliasson
* 	@copyright	Copyright (C) 2010 Stilero. All rights reserved.
* 	@license	GNU/GPL, see LICENSE.php
* 	Joomla! is free software. This version may have been modified pursuant
* 	to the GNU General Public License, and as distributed it includes or
* 	is derivative of works licensed under the GNU General Public License or
* 	other free or open source software licenses.
*/
?>
<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>
	<div class="product_categories<?php echo $params->get('moduleclass_sfx'); ?>">
		<?php $i=1; ?>
		<?php foreach ($list['category_tmp'] as $item){?>
			<?php if($item['category_parent_id']==0 && $i<=$params->get('numParents')) { ?>
				<div class="prod_category cat<?php print $i++; ?>" >
				<?php $parentlink = JRoute::_('index.php?option=com_virtuemart&amp;page=shop.browse&amp;Itemid=2&amp;category_id='.$item['category_child_id']); ?>
				<a href="<?php print $parentlink; ?>" class="parentcat parent<?php print $i; ?>"><?php print $item['category_name'] ?></a>
				<?php 
				//Check if chache is activated
				if ($params->get('cache')){
					//Force cache activate	
					$cache =& JFactory::getCache('mod_vm_categoryshortcut');
					$cache->setCaching( 1 );
					$method = array($ps_product_category, 'get_child_list');
					$children = $cache->call($method, $item['category_child_id']);
				}else{
					$cache =& JFactory::getCache('mod_vm_categoryshortcut');
					$children = $ps_product_category->get_child_list($item['category_child_id']);
				}

				if($children!="") {?>					
					<ul>
					<?php $j=1; ?>
					<?php foreach($children as $child) { ?>
						<?php if ($j++ <= $params->get('numChild')){ ?>
						<?php $childlink = JRoute::_('index.php?option=com_virtuemart&amp;page=shop.browse&amp;Itemid=2&amp;category_id='.$child['category_id']); ?>
						<li><a href="<?php print $childlink; ?>" ><?php print $child['category_name']; ?></a></li>
						<?php } ?>
					<?php } ?>
					</ul>
				<?php } ?>
				<a href="<?php print $parentlink; ?>" class="parent_all" rel="nofollow">Visa alla...</a>
				</div>
			<?php } ?>
		<?php } ?>
		</div>